img_list()
var totalPage = 1;
function img_list() {
	$.ajax({
		type: "POST",
		url: root.dockingplatform.queryProof,
		cache: false, //禁用缓存
		data: {
			"orderId":sessionStorage.getItem("orderId")
			},
		success: function(data) {
			if(data.errorCode == 0) {
				var imgHtmlStr = "";
                var objList = data.data;
				if(objList != null) {
					for(var i = 0; i < objList.length; i++) {
						if (objList[i].proofUrl != null && objList[i].proofUrl != "null") {
							imgHtmlStr += '<li><img onclick="picShow(\'查看图片\',\'picShow.html\',\'' + objList[i].proofUrl + '\')" src="' + objList[i].proofUrl + '"></li>';
						}
					}
					$("#imgListBox").html(imgHtmlStr);
				}
				power();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest);
		}
	});
}

function picShow(title, url, imgUrl) {
	window.event ? window.event.cancelBubble = true : e.stopPropagation();
	sessionStorage.setItem("imgUrl", imgUrl);
	layer_show(title, url, "800", "500");
}

function addImg() {
	layer_show("增加图片", "addPic.html", "600", "500");
}

function updataImg(imgId) {
	$.ajax({
		contentType: "application/json",
		type: "POST",
		url: root.goodsInter.goods_getImg,
		cache: false, //禁用缓存
		dataType: "json",
		data: JSON.stringify({
			"imgId": imgId
		}),
		success: function(data) {
			console.log(data);
			if(data.errorCode == 0) {
				// 未使用，随便修
				sessionStorage.setItem("imgInfo", JSON.stringify(data));
				layer_show("修改图片", "can-updataImg.html", "600", "400");

				/*if(data.use_img == 0) {
				} else if(data.use_img == 1) {
					//已使用，只能修改名字
					sessionStorage.setItem("imgInfo", JSON.stringify(data));
					layer_show("修改图片", "cannot-updataImg.html", "600", "400");
				}*/
			}

		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert(XMLHttpRequest);
		}
	});
}

function deleteImg(imgId) {
	layer.confirm('确认要删除吗？', function(index) {
		$.ajax({
			contentType: "application/json",
			type: "POST",
			url: root.goodsInter.goods_delImg,
			cache: false, //禁用缓存
			dataType: "json",
			data: JSON.stringify({
				"imgId": imgId
			}),
			success: function(data) {
				console.log(data);
				if(data.errorCode == 0) {
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					layer.msg("删除成功", {
						icon: 6,
						time: 1000
					}, function() {
						img_list();
					});
				} else {
					layer.msg(data.errorMessage, {
						icon: 5,
						time: 1000
					}, function() {
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					});
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest);
			}
		});
	});
}

function setBtnDis(num, pnode) { //如果选中项为空时，置灰相关按钮
	if(num <= 0) {
		pnode.find(".goods_edit").attr("disabled", "disabled").addClass("dis_btn");
	} else {
		pnode.find(".goods_edit").removeAttr("disabled").removeClass("dis_btn");
	}
}